; sample logging configuration file for openport 2.0
; must be named logcfg.txt and be placed in the root directory of the
; microSD card inserted in the openport in order to work

; this sample logs using the SSM protocol over the K-line, which works
; for both CAN-based and older Subarus

;----------------ssm----------------
; log channel settings

; we are logging SSM via the K-line
type=ssmk				

; each parameter gets a name you chose
paramname = RPM				

; the paramid is used in the SSM request
paramid = 0x0E				

; how many bits in the returned value (defaults to 8, so you usually don't need to specify this)
databits = 16				

; how to scale the results using a RPN (http://en.wikipedia.org/wiki/Reverse_Polish_notation) notation, with data and operators seperated by commas
; the operators are as following:
;       + : add
;       - : subtract
;       * : multiply
;       / : divide
;
;       x : represents the raw (unscaled) parameter
; 123.456 : example of a constant
;
; if no scaling is specified, the raw value will be used
;
; the OP2 has no FPU - it must do floating point calculations in software which can 
; create performance issues, so be efficient in your RPN expressions by doing the following:
;
; * minimize the number of operations; e.g. ((x * 2) + 1) * 2 => x * 4 + 2
; * don't divide by a constant when you can multiply instead; e.g. x / 4 => x * 0.25
; * don't make constant expressions that can instead be pre-calculated; e.g. x * 3 / 4 => x * 0.75

scalingrpn = x,0.25,*	

; continue specifying other parameters
paramname = load
paramid = 0x07
scalingrpn = x,0.3921569,*

; commented out here is an example for reading a direct RAM parameter, a 32-bit float in this case
;paramname = load
;paramid = 0xFF6578
;isfloat = 1 ; the raw data is a 32-bit floating point number (no need to set databits = 32)

paramname = speed
paramid = 0x10
scalingrpn = x,0.621371192,*

; Notice that the next 3 parameters have a "sampgroup = 1" setting.
; There are 15 sample groups (1 - 15) that you can assign parameters to. 
; Any parameters assigned to a sample group will be alternately logged in a single
; timeslot at a lower speed, the speed being 1 / N that of the sampling interval -
; where N is the number of parameters in the sample group. In this example, these
; 3 parameters will be logged at 1/3 the speed, but will also use 1/3 of the communications
; to the ECU, allowing you to log everything else faster.
; Since you can make up multiple sample groups, you can fine tune how fast different kinds of
; parameters are logged.

paramname = IAT
paramid = 0x12
scalingrpn = x,0.40,-
sampgroup = 1

paramname = coolant_temp
paramid = 0x08
scalingrpn = x,0.40,-
sampgroup = 1

paramname = battery_volts
paramid = 0x1C
scalingrpn = x,0.08,*
sampgroup = 1

paramname = mrp
paramid = 0x24
scalingrpn = x,128,-,0.145098,*

paramname = MAF
paramid = 0x13
databits = 16				
scalingrpn = x,0.01,*

paramname = throttle
paramid = 0x15
scalingrpn = x,0.3921569,*

paramname = timing
paramid = 0x11
scalingrpn = x,128,-,0.5,*

paramname = WGDC
paramid = 0x30
scalingrpn = x,0.3921569,*

paramname = IPW ; injector #1 pulse width
paramid = 0x11
scalingrpn = x,0.256,*

paramname = IAM
paramid = 0xF9
scalingrpn = x,0.0625,*

; some samples of logging "bitfield" values that are not whole bytes
; if you want to log more that one of these efficently, group them by
; paramid and the OP2 will only issue a single request to get all of 
; the bits within each paramid

paramname = ignition_sw
paramid = 0x62
databits = 1
offsetbits = 3

; to still acquire a parameter (perhaps for triggering or a calculation)
; but not record it in the log, set isvisible equal to zero (it is 1 by default)
isvisible = 0 

paramname = AC_sw
paramid = 0x62
databits = 1
offsetbits = 1
isvisible = 0 

paramname = defogger_sw
paramid = 0x64
databits = 1
offsetbits = 5
isvisible = 0 

paramname = blower_sw
paramid = 0x64
databits = 1
offsetbits = 4
isvisible = 0 

paramname = clutch_sw
paramid = 0x121
databits = 1
offsetbits = 7

paramname = brake_sw
paramid = 0x121
databits = 1
offsetbits = 3

;----------------inno----------------
type=inno
; log from an innovate MTS bus via the 3/32" jack
; multiple LC-1 and other MTS devices (e.g. TC-4) are supported
;
; each MTS parameter has a special parameter ID:
;
; paramid   parameter
; 0x0101    LC-1 #1 lambda
; 0x0102    LC-1 #1 AFR
; 0x0201    LC-1 #2 lambda
; 0x0202    LC-1 #2 AFR
; 0x0301    LC-1 #3 lambda
; 0x0302    LC-1 #3 AFR
;           (etc)
;
; 0x0001    aux #1 data (e.g. TC-4 #1 channel 1)
; 0x0002    aux #2 data (e.g. TC-4 #1 channel 2)
; 0x0003    aux #3 data (e.g. TC-4 #1 channel 3)
; 0x0004    aux #4 data (e.g. TC-4 #1 channel 4)
; 0x0005    aux #5 data (e.g. TC-4 #2 channel 1)
;           (etc)

; the LC-1 parameters are already scaled correctly and require no scalingrpn setting
; however, the LC-1 is known to lose its stored AFR multiplier, so we recommend calculating
; AFR from lambda like this

;paramname = mylc1.afr
;paramid = 0x0101       ; get lambda from first LC-1
;scalingrpn = x,14.7,*  ; scale to an AFR

; since the MTS bus does not describe the contents of the aux channels, you need to know what they are
; and how to scale them. in this example we assume you have a TC-4 connected and you want to view the
; thermocouple readings in celsius, two of which are in the EGT mode, two in CHT mode

;paramname = mytc4.egt1
;paramid = 0x0001
;scalingrpn = x,1.06842619,*

;paramname = mytc4.egt2
;paramid = 0x0002
;scalingrpn = x,1.06842619,*

;paramname = mytc4.cht1
;paramid = 0x0003
;scalingrpn = x,0.293255131,*

;paramname = mytc4.cht2
;paramid = 0x0004
;scalingrpn = x,0.293255131,*

;----------------adc----------------
type=adc 		; log from built in ADC channels

paramname=battvolts
paramid=16		; paramid is pin number on OBD connector
			; valid pins are 8,12 and 16
			; values are pre-scaled to millivolts
scalingrpn=x,0.001,*    ; here we scale to volts

paramname=ignvolts	; on newer subarus pin 8 is connected to the ignition voltage
paramid=8		; paramid is pin number on OBD connector
			; valid pins are 8, 12 and 16
			; values are pre-scaled to millivolts
scalingrpn=x,0.001,*    ; here we scale to volts


;-------------calculated parameter---------------
;
; you can derive calculated parameters from other parameters
; using RPN expressions
;
type = calc				

paramname = IDC
scalingrpn = RPM,IPW,*,0.0008333333,*


;-------------triggers---------------
;
; note that parameters must be previously defined 
; before defining triggers using them
;
; triggers allow you to control when logging starts and stops
; this example sets up triggers such that logging only occurs
; when the engine is running (RPM > 0)
;
; triggers consist of a condition (a RPN expression using comparison operators)
; and an action. the RPN comparison operators match those in the C language:
;
; > < >= <= == != && ||
;
; if the condition evaluates to a non-zero value, that action is taken
;
; note that it is not required to have triggers in order to log - if no triggers
; are present, logging will start by default

conditionrpn = RPM,0,>	
action = start

conditionrpn = RPM,0,==
action = stop

; here is a second triggering example using the rear defogger switch
; uncomment it and comment out the sample above to use it

;conditionrpn = defogger_sw,1,==
;action = start

;conditionrpn = defogger_sw,0,==
;action = stop

